package com.czy.owner.api;

import android.text.TextUtils;

import com.czy.owner.net.api.BaseApi;
import com.czy.owner.net.listener.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

import java.util.HashMap;

import retrofit2.Retrofit;
import rx.Observable;

/**
 * Created by asus on 2017/7/1.
 */

public class GoodsRemainCountApi extends BaseApi {
    private String session;
    private String goodsIds;
    private String specGroupKeys;
    private String numbers;
    private String formShoppingCar;
    private String ownerCarId;

    public String getOwnerCarId() {
        return ownerCarId;
    }

    public void setOwnerCarId(String ownerCarId) {
        this.ownerCarId = ownerCarId;
    }

    public String getGoodsIds() {
        return goodsIds;
    }

    public void setGoodsIds(String goodsIds) {
        this.goodsIds = goodsIds;
    }

    public String getSpecGroupKeys() {
        return specGroupKeys;
    }

    public void setSpecGroupKeys(String specGroupKeys) {
        this.specGroupKeys = specGroupKeys;
    }

    public String getFormShoppingCar() {
        return formShoppingCar;
    }

    public void setFormShoppingCar(String formShoppingCar) {
        this.formShoppingCar = formShoppingCar;
    }

    public String getNumbers() {
        return numbers;
    }

    public void setNumbers(String numbers) {
        this.numbers = numbers;
    }

    public GoodsRemainCountApi(HttpOnNextListener listener, RxAppCompatActivity rxAppCompatActivity) {
        super(listener, rxAppCompatActivity);
        setShowProgress(true);
        setCache(true);
        setCookieNetWorkTime(0);

    }

    public String getSession() {
        return session;
    }

    public void setSession(String session) {
        this.session = session;
    }


    @Override
    public Observable getObservable(Retrofit retrofit) {
        HttpPostService service = retrofit.create(HttpPostService.class);
        HashMap<String, Object> map = new HashMap<>();
        map.put("session", getSession());
        map.put("goodsIds", getGoodsIds());
        map.put("specGroupKeys", getSpecGroupKeys());
        map.put("numbers", getNumbers());
        if(!TextUtils.isEmpty(getOwnerCarId())){
            map.put("ownerCarId",getOwnerCarId());
        }

        return service.getGoodsRemainCount(map);
    }
}


